<?xml version="1.0"?>

<!--
    Document   : showOrderDetail.xsl
    Created on : June 10, 2013, 12:54 AM
    Author     : TuPA
    Description:
        Purpose of transformation follows.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html"/>

    <xsl:variable name="order" select="document('../XML/listOrder.xml')"/>

    <xsl:template name="formatdate">
        <xsl:param name="datestr" />
        <xsl:variable name="mm">
            <xsl:value-of select="substring($datestr,6,2)" />
        </xsl:variable>
        <xsl:variable name="dd">
            <xsl:value-of select="substring($datestr,9,2)" />
        </xsl:variable>
        <xsl:variable name="yyyy">
            <xsl:value-of select="substring($datestr,1,4)" />
        </xsl:variable>
        <xsl:variable name="hh">
            <xsl:value-of select="substring($datestr,12,2)" />
        </xsl:variable>
        <xsl:variable name="mimi">
            <xsl:value-of select="substring($datestr,15,2)" />
        </xsl:variable>
        <xsl:variable name="ss">
            <xsl:value-of select="substring($datestr,18,2)" />
        </xsl:variable>
        <xsl:value-of select="$yyyy" />
        <xsl:value-of select="'-'" />
        <xsl:value-of select="$mm" />
        <xsl:value-of select="'-'" />
        <xsl:value-of select="$dd" />
    </xsl:template>

    <xsl:template match="OrderDetails">
        <div class="onecolumn" >
            <div class="content"  >
                <div class="tableName">
                    <h3 id="pickMonth">Detail information of Order
                    </h3>
                    <table>
                        <thead>
                            <tr>
                                <th class="border">
                                    <div>No.</div>
                                </th>
                                <th class="border">
                                    <div>Product Image</div>
                                </th>
                                <th class="border">
                                    <div>Product Name</div>
                                </th>
                                <th class="border">
                                    <div>Product Price</div>
                                </th>
                                <th class="border">
                                    <div>Quantity</div>
                                </th>
                                <th class="border">
                                    <div>Total Price</div>
                                </th>
                                <th class="border">
                                    <div>Date of order</div>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <xsl:for-each select="OrderDetail">
                                <tr>
                                    <td class="border">
                                        <xsl:number level="single" count="OrderDetail"/>
                                    </td>
                                    <td class="border">
                                        <img width="50px" height="60px">
                                            <xsl:attribute name="src">
                                                <xsl:value-of select="proImage"/>
                                            </xsl:attribute>
                                        </img>
                                    </td>
                                    <td class="border">
                                        <xsl:value-of select="proName"/>
                                    </td>
                                    <td class="border">
                                        <xsl:value-of select="format-number(Price,'###,###,##0')"/>
                                    </td>
                                    <td class="border">
                                        <xsl:value-of select="Quantity"/>
                                    </td>
                                    <td class="border">
                                        <xsl:value-of select="format-number(totalPrice,'###,###,##0')"/>
                                    </td>
                                    <td class="border">
                                        <xsl:call-template name="formatdate">
                                            <xsl:with-param name="datestr" select="orderDate"/>
                                        </xsl:call-template>
                                    </td>
                                </tr>
                            </xsl:for-each>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </xsl:template>

</xsl:stylesheet>

